import { RouteRecordRaw } from "vue-router";
import FrontHome from "../view/front.vue/index.vue";
import AdminHome from "../view/admin/index.vue";
import Admin from "../layout/admin.vue";
import Front from "../layout/front.vue";
import ListBase from "../view/admin/listPages/base.vue";
import FormBase from "../view/admin/formPages/base.vue";
import ModalForm from "../view/admin/formPages/modalForm.vue";
import NotFound from "../view/notFount.vue";
import Login from "../view/auth/login.vue";
import Register from "../view/auth/register.vue";

const routes = [
  {
    path: "/",
    redirect: "/admin/home",
  },
  { path: "/:pathMatch(.*)*", name: "NotFound", component: NotFound },
  {
    path: "/auth",
    meta: {
      visitor: true, // 游客登录可以访问的页面
    },
    children: [
      { path: "login", name: "Login", component: Login },
      { path: "register", component: Register },
    ],
  },
  {
    path: "/admin",
    component: Admin,
    children: [
      { path: "home", component: AdminHome },
      { path: "list/base", component: ListBase },
      { path: "form/base", component: FormBase },
      { path: "form/modalForm", component: ModalForm },
    ],
  },
  {
    path: "/front",
    component: Front,
    children: [
      {
        path: "home",
        name: "FrontHome",
        component: FrontHome,
        meta: {
          visitor: true,
        },
      },
    ],
  },
] as RouteRecordRaw[];

export default routes;
